# -*- conding:UTF-8 -*-

'''
@ Project: P8_02_LumenIM-flask
@ File: upload_app.py
@ Author: 罗婷
@ Date：2022/7/11 15:40

'''
import json

import redis
from flask import Blueprint, jsonify, g
from flask_restful import Api, Resource, reqparse, marshal
from qiniu import Auth


upload_bp = Blueprint('upload_bp', __name__, url_prefix='/api/v1/upload')
api = Api(upload_bp)

access_key = '74F2GCXwNJ2c9fgiD3ufHUUDXUrSdgNXW6kmIrXY'
secret_key = 'LqiDv9FZT8oLhDMHrLWwR-HP1vOoEguyQWUQlmNz'
# 上传图片到服务器
class ImageCaijan(Resource):
    def post(self):
        # data.avatar
        # 空间: p8lotk
        # 域名: http: // reu1ifn21.hn - bkt.clouddn.com
        # 上传地址: 华南源站上传
        # http: // up - z2.qiniup.com
        # q = Auth(access_key, secret_key)
        # bucket = 'p8lotk'
        # token = q.upload_token(bucket)
        # return token
        parser = reqparse.RequestParser()
        parser.add_argument('form')
        args = parser.parse_args()
        form = args['form']
        print('接收到的文件是form`````~~~~~~~~~~~~~~', form)
        return 'nnn'


# 上传头像裁剪图片服务接口
api.add_resource(ImageCaijan, '/avatar')